
import 'package:flutter_app/openeye/http/http_manager.dart';
import 'package:flutter_app/openeye/http/url.dart';
import 'package:flutter_app/openeye/model/common_item.dart';
import 'package:flutter_app/openeye/model/issue_model.dart';
import 'package:flutter_app/openeye/utils/toast_utils.dart';
import 'package:flutter_app/openeye/viewmodel/base_change_notifer.dart';
import 'package:flutter_app/openeye/widget/loading_state_widget.dart';
import 'package:chewie/chewie.dart';
class HomePageViewModel extends BaseChangeNotifier{
  List<Item> bannerList = [];

  void refresh(){
    HttpManager.getData(Url.feedUrl,success: (json){
      var issueEntity = IssueEntity.fromJson(json);
      bannerList = (issueEntity.itemList == null)?[]:issueEntity.itemList!;
      bannerList.removeWhere((element) => element.type == 'banner2');
      viewState = ViewState.done;
    },fail: (e){
      ToastUtils.showError(e.toString());
      },
    complete: ()=>notifyListeners()
    );
  }
  retry(){
    viewState = ViewState.loading;
    notifyListeners();
    refresh();
  }
}